package com.itheima.demo1;

import java.util.Arrays;
import java.util.Comparator;

public class LambdaDemo1 {
    public static void main(String[] args) {

        String[] arr = {"a","aaa","aaaa","aa"} ;

        //匿名内部类的书写规则
        Arrays.sort(arr, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {

                return o1.length() - o2.length();
            }
        });

        //lambda表达式的简化书写结果
        Arrays.sort(arr, (String o1, String o2) -> o1.length() - o2.length());

        System.out.println(Arrays.toString(arr));

    }
}
